package com.itheima.sharding.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderDao {
    @Insert("insert into t_order(price,user_id,status)values(#{price},#{userId},#{status})")
    int insertOrder(@Param("price")BigDecimal price,@Param("userId")long userId,@Param("status")String status);

    /**
     * 拼写语句注意字段间空格
     */
    @Select("<script>"+
            "select"+
            "*"+
            "from t_order t "+
            "where t.order_id in "+
            "<foreach collection='orderIds' open='(' separator=',' close=')' item='id'>"+
            "#{id}"+
            "</foreach>"+
            "</script>")
    List<Map> qryOrderByIds(@Param("orderIds") List<Long> orderIds);
}
